package com.xinjie.www.servlet;

import com.xinjie.www.service.manager.ManagerServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class ManagerServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        int userId = Integer.parseInt(req.getParameter("userId"));
        int tiebaId = Integer.parseInt(req.getParameter("tiebaId"));
        ManagerServiceImpl managerService = new ManagerServiceImpl();
        boolean b = managerService.doBan(userId, tiebaId);
        if (b){
            req.getSession().setAttribute("BanSuccess","封禁成功");
            resp.sendRedirect("/ManagerPage/ManagerComment.jsp");
        }else {
            req.getSession().setAttribute("BanLose","封禁失败");
            resp.sendRedirect("/ManagerPage/ManagerComment.jsp");
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }


}
